using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace dohoa2
{
    abstract public class Chinhve
    {
// Add a new comment
        public Color maunen, mauve = Color.Green;
        public Bitmap anh;

        public string name = "hinhve";
        public int kichthuoconho = 4;
        public bool duocchon = false;


        public virtual void ve() { }
        public virtual void vechon() { }


        public virtual void tinhtien(Point mot, Point hai) { }


        public virtual bool kiemtraduocchon(Point p)
        {

            return false;
        }


        public void veonho(int x, int y)
        {
            int i;
            try
            {
                for (i = 0; i < 2 * kichthuoconho; i++)
                {
                    anh.SetPixel(x - kichthuoconho + i, y - kichthuoconho, mauve);
                    anh.SetPixel(x - kichthuoconho + i, y + kichthuoconho, mauve);

                    anh.SetPixel(x - kichthuoconho, y - kichthuoconho + i, mauve);
                    anh.SetPixel(x + kichthuoconho, y - kichthuoconho + i, mauve);

                }
            }
            catch { }

        }

        public void bochon()
        {
            Color mauluu = new Color();
            mauluu = mauve;
            mauve = maunen;
            vechon();
            mauve = mauluu;
        }
        public virtual void quay(Point mot, Point hai) { }
        public virtual void quay1goc(int goc) { }



        public virtual void hienthuoctinh() { }
       /* public void tinhtienchung(int loaihinh,  Chinhchunhat  bien, Point mot, Point hai)
        {
            int dx, dy;
            Color mauluu = new Color();
            mauluu = bien.mauve;
            bien.mauve = bien.maunen;

            bien.ve();
            if (bien.duocchon == true) bien.bochon();

            bien.mauve = mauluu;
            dx = hai.X - mot.X;
            dy = hai.Y - mot.Y;
            switch (loaihinh)
            {
                case 1:
                    if ((bien.dau.X + dx - kichthuoconho / 2 >= 0) && (bien.dau.X + dx + kichthuoconho / 2) <= bien.anh.Width
                && (bien.cuoi.X + dx - kichthuoconho / 2) >= 0 && (bien.cuoi.X + dx + kichthuoconho / 2) <= bien.anh.Width
                && (bien.dau.Y + dy - kichthuoconho / 2 >= 0) && (bien.dau.Y + dy + kichthuoconho / 2) <= bien.anh.Height
                && (bien.cuoi.Y + dy - kichthuoconho / 2) >= 0 && (bien.cuoi.Y + dy + kichthuoconho / 2) <= bien.anh.Height
                        )
                    {
                        bien.dau.X += dx;
                        bien.cuoi.X += dx;
                        bien.dau.Y += dy;
                        bien.cuoi.Y += dy;
                    }; break;
                case 2: //dau.x la xc, dau.y la yc, cuoi.x la r
                    if ((dau.X + cuoi.X + dx - kichthuoconho / 2 >= 0) && (dau.Y + cuoi.X + dx + kichthuoconho / 2) <= bien.anh.Width
                && (dau.Y + cuoi.X + dy - kichthuoconho / 2) >= 0 && (dau.Y + cuoi.X + dy + kichthuoconho / 2) <= bien.anh.Height
                      )
                    {

                        bien.dau.X += dx;
                        bien.dau.Y += dy;

                    }; break;
          

            }
        }*/

        public int dodai(Point a, Point b)
        {
            return (int)Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));

        }
        public long dodaimu2(Point a, Point b)
        { return (long)dodai(a, b) * (long)dodai(a, b); }
    }
}